<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="xianshi">显示仓库的内容</button>
        <h1>{{this.$store.state.counter}}</h1>
        <button @click="jia">+</button>
    </div>
</body>
<script src="./node_modules/vue/dist/vue.js"></script>
<!-- 1. 引入 vuex 依赖 -->
<script src="./node_modules/vuex/dist/vuex.js"></script>
<script>
    console.log(Vuex);
    // 2. 创建仓库
    let store = new Vuex.Store({
         state:{
             counter:888
         },
         //改变值的操作
         mutations:{
             increment:function(state,{count}){
                 state.counter+=count;
             }
         }
    })
    let vm = new Vue({
        store,
        el:"#app",
        methods: {
            xianshi:function(){
                console.log(this.$store);
            },
            jia:function(){
                // this.$store.commit("increment",10)
                this.$store.commit({
                    type:"increment",
                        count:10
                })
            }
        },
    })
</script>
</html>